﻿using System.Windows;
using System.Windows.Controls;
using StockholmsStad.Windows.UI.Modules.Minister.Models;

namespace StockholmsStad.Windows.UI.Modules.Minister.Controls
{
    /// <summary>
    /// Interaction logic for PrintSelector.xaml
    /// </summary>
    public partial class PrintSelector
    {
        public PrintSelector()
        {
            InitializeComponent();

            btnPrint.Click += btnPrint_Click;
            btnCancel.Click += btnCancel_Click;
        }

        public MinisterPresentationModel Model { get; set; }

        private void btnPrint_Click(object sender, RoutedEventArgs e)
        {
            if (Model != null)
            {
                if(Model.ReimbursementDate.HasValue)
                {
                    Model.PrintMinisterReimbursementCommand.Execute(Model);
                }
            }

            Close();
        }

        private void btnCancel_Click(object sender, RoutedEventArgs e)
        {
            Close();
        }

        public void Close()
        {
            var window = ((StackPanel) Parent).Parent as Window;

            if (window != null)
                window.Close();
        }

    }
}
